Skip to content

feat: added --dry-run to wkg publish#210

Merged
lann merged 6 commits into
bytecodealliance:mainfrom
mkatychev:feat/publish-dry-run
Jun 2, 2026
Merged

feat: added --dry-run to wkg publish#210
lann merged 6 commits into
bytecodealliance:mainfrom
mkatychev:feat/publish-dry-run

Conversation

@mkatychev

Copy link
Copy Markdown
Member

Added ability to dry run publication for the three supported backends attempting to do as many of the present logical steps, stopping short of doing the publication itself.

Added various logging steps for issues I ran into attempting to publish to OCI that were not currently evident.

impl Config {
/// Loads a configuration file from the given path.
pub async fn load_from_path(path: impl AsRef<Path>) -> Result<Config> {
tracing::info!(path = %path.as_ref().display(), "loading wkg config file");

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is unfortunate that the tracing deps has to be added for this line but it was particularly valuable to have visibility in what file actually gets resolved here.

@mkatychev mkatychev changed the title feat: added --dry-run to wkg publishgg feat: added --dry-run to wkg publish Jun 2, 2026
load_package(&mut self.packages, &self.client, dependency.package.clone())
.await?
.await
.with_context(|| format!("package: {}", dependency.package.clone()))?

@lann lann Jun 2, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a dupe with the next line?

Suggested change
.with_context(|| format!("package: {}", dependency.package.clone()))?

@mkatychev mkatychev Jun 2, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought so too, but if you look, the next line is actually an option because load_package returns Result<Option<T>> so the added with_context is if the loading logic failed rather than if the package exists (this issue I specifically ran into).

async fn load_package<'b>(
packages: &'b mut HashMap<PackageRef, Vec<VersionInfo>>,
client: &CachingClient<FileCache>,
package: PackageRef,
) -> Result<Option<&'b Vec<VersionInfo>>> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah confusing!

let name = super::package_ref_to_name(package)?;

if dry_run {
return Ok(());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally fine if you don't want to make this change but for dry runs I've found it can be nice to model them as an error variant, e.g.

Suggested change
return Ok(());
return Err(Error::DryRun);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm following cargo publish --dry-run logic as much as possible and they seem to throw an exit code of zero.

I also use cargo publish dry runs as CI steps that would abort on exit code so this would cause issues if one wanted to check that a current commit/PR would be able to publish.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you would catch the varient down-stack and exit 0. Anyway definitely not a blocker.

@lann lann left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll merge whenever you're ready.

@mkatychev

Copy link
Copy Markdown
Member Author

Ready now, @lann. I have a follow-up PR to thins that allows wkg publish to point to a directory as well, this should open the way for us to publish multiple packages at once (semi) atomically.

@lann lann merged commit 4acb920 into bytecodealliance:main Jun 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants